package com.cl.security.core.entity;

import com.cl.security.base.entity.BaseEntity;
import com.cl.security.system.entity.FileInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

@Entity
@Table(name = "mall_sku")
@Getter
@Setter
//@SQLDelete(sql = "update mall_sku set deleted=1 where id=?")
@Where(clause = "deleted<>1")
public class Sku extends BaseEntity {

    private int stock;



    @ManyToOne
    @JsonIgnoreProperties({"skus"})
    private Product product;
    @ManyToMany(cascade = CascadeType.ALL)
    @JsonIgnoreProperties({"product"})
    @JoinTable(name = "mall_sku_property_value",joinColumns = @JoinColumn(name = "sku_id"),inverseJoinColumns = @JoinColumn(name = "property_value_id"))
    @OrderBy("propertyId")
    private Set<PropertyValue> propertyValues = new LinkedHashSet<>();


}
